//
//  LWWelcomeVc.m
//  1.28  weibo
//
//  Created by mac on 15/2/3.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "LWWelcomeVc.h"
#import "UIButton+WebCache.h"
#import "LWAccount.h"
#import "LWTabBarController.h"

@interface LWWelcomeVc ()
@property (weak, nonatomic) IBOutlet UIImageView *iconView;

@property (weak, nonatomic) IBOutlet UILabel *welcomeLable;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *iconCenterY;


@end

@implementation LWWelcomeVc

- (void)viewDidLoad {
    [super viewDidLoad];
    //1.设置圆角
    self.iconView.layer.cornerRadius = 50;
    self.iconView.layer.masksToBounds = YES;
    //2.加载图片
    LWAccount *account = [LWAccount accountFromSandBox];
    NSString *imageUrl = account.profile_image_url;
    NSURL *url = [NSURL URLWithString:imageUrl];
    SDWebImageManager *manger = [SDWebImageManager sharedManager];
    [manger downloadImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
        self.iconView.image = image;
    }];

}

- (void)viewDidAppear:(BOOL)animated{

    [super viewDidAppear:animated];
    [UIView animateWithDuration:1 animations:^{
        self.iconCenterY.constant += 150;
        [self.view layoutIfNeeded];
    } completion:^(BOOL finished) {
        
        [UIView animateWithDuration:1 animations:^{
            self.welcomeLable.alpha = 1.0;
        } completion:^(BOOL finished) {
            LWTabBarController *tab = [[LWTabBarController alloc] init];
            UIWindow *windou = [UIApplication sharedApplication].keyWindow;
            windou.rootViewController = tab;
        }];
    }];
}




@end
